using System.IO;

namespace Synergy.IO.Extensions
{
	/// <summary>
	/// Static methods extending the <see cref="File"/> class.
	/// </summary>
	/// <remarks>
	///		<list type="table">
	///			<listheader><term>Version</term><description>Description</description></listheader>
	///			<item>
	///				<term>1.0</term>
	///				<description>Initial version</description>
	///			</item>
	///		</list>
	/// </remarks>
	public static class FileExtension
	{
		/// <summary>
		/// Copies the specified <paramref name="sourceFile"/> if it exists.
		/// </summary>
		/// <param name="sourceFile">The file to copy.</param>
		/// <param name="destinationFile">The destination file.</param>
		/// <param name="overwrite">if set to <c>true</c> [overwrite].</param>
		public static void CopyIfExists(string sourceFile, string destinationFile, bool overwrite)
		{
			if (File.Exists(sourceFile))
			{
				File.Copy(sourceFile, destinationFile, overwrite);
			}
		}


		/// <summary>
		/// Deletes the specified <paramref name="file"/> if it exists.
		/// </summary>
		/// <param name="file">The file to delete.</param>
		public static void DeleteIfExists(string file)
		{
			if (File.Exists(file))
			{
				File.Delete(file);
			}
		}
	}
}